#encoding=utf-8
'''
Created on 2013-2-20

@author: Administrator
'''
from actionModule.handle import base
import json
from base.common import retSuccess, execMysql


class relaForm(base):
    
    def qryRela(self):
        projectId=self.getPost("id")
        sql=[]
        sql.append("select b.id,b.remark from db_relaform a,db_html b,db_project c ")
        sql.append("where b.id=a.form_id and c.id=a.project_id ")
        sql.append("and a.project_id= ")
        sql.append(projectId)
        return execMysql("".join(sql))
        
    def saveRela(self):
        projectId=self.getPost("id")
        self.table.objects.filter(project_id=projectId).delete()
        forms=self.getPost("forms")
        forms=json.loads(forms)
        for item in forms:
            temp=self.table()
            temp.form_id=item
            temp.project_id=projectId
            temp.save()
        return retSuccess("保存成功")